{include file='common/head'}
<script type="text/javascript" src="__STATIC__/js/jquery.min.js"></script>
<style type="text/css">
    imges{float: left;cursor:pointer;width:100px;height:100px}
</style>
<body>
<form class="layui-form" action="">
<table class="layui-table" >
    <thead>
    <tr>
        <th style="text-align: center">二维码</th>
        <th style="text-align: center">操作 </br>(锁定二维码不可用)</th>
    </tr>
    </thead>
    {volist name="a" id="a" }
    <tbody>
    <tr style="text-align: center">
        <td><a title="{$a.qid}" href="javascript:;" attr_id='{$a.qid}' onclick="banner_new(this)"><img src="/upload/ewm/{$a.q_picture}" name="imges" id="imges" style="cursor:pointer;width:100px;height:100px"></a></td>
        <td class="td-manage">
            <input type="checkbox" <?php if ($a['q_state'] ==0): ?>  checked="" <?php endif; ?> name="status[]" lay-skin="switch" lay-filter="switchSuodoing" lay-text="锁定|解锁" value="{$a.qid}">
        </td>
    </tr>
    </tbody>
    {/volist}
</table>
</form>
<script src="__STATIC__/lib/layui/layui.js"></script>
<script src="__STATIC__/js/jquery-3.3.1.min.js"></script>
<script>
    function banner_new(obj){
        var tid=$(obj).attr('attr_id');
        var url="{:Url('admin/qrcode/ewmxq')}?qid="+  tid;
        x_admin_show('查看',url);
    }
    layui.use(['laydate','form'], function() {
        var laydate = layui.laydate;
        var form = layui.form;
        //执行一个laydate实例
        form.on('switch(switchSuodoing)', function (data) {
            var id = data.value;
            //监听提交
            $.ajax({
                url: "{:url('admin/qrcode/suoding')}",
                type: "post",
                dataType: "JSON",
                data: {qid: id},
                success: function (res) {
                    if (res == 1) {
                        layer.msg('操作成功！');
                        return false;
                    } else if(res==0){
                        layer.msg('操作失败！');
                        return false;
                    }
                }
            });
        });
    });
</script>
</body>

</html>